package com.sixseven.config;

import com.sixseven.interceptor.AdminInterceptor;
import com.sixseven.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author Belly
 * @version 1.1.0
 */
@Configuration
public class WebConfig {
    @Bean
    public WebMvcConfigurer webMvcConfigurer(){
        return new WebMvcConfigurer() {
            @Override
            public void addInterceptors(InterceptorRegistry registry) {
                registry.addInterceptor(new LoginInterceptor())
                        .addPathPatterns("/**")
                        .excludePathPatterns(
                                "/userLogin", "/userRegister",
                                "/userStatus", "/cowryList",
                                "/listPageByConditionName", "/addCartItem",
                                "/cartList", "/modify",
                                "/delete/*", "/annList",
                                "/addComment/*", "/searchByName",
                                "/orderItemList/*", "/addOrder");
            }
        };
    }
    @Bean
    public WebMvcConfigurer webMvcAdminConfigurer(){
        return new WebMvcConfigurer() {
            @Override
            public void addInterceptors(InterceptorRegistry registry) {
                registry.addInterceptor(new AdminInterceptor())
                        .addPathPatterns(
                                "/addCowry", "/upload",
                                "/deleteCowry/*", "/modifyCowry",
                                "/deleteLastImg", "/memberList",
                                "/memberStatus", "/delMember/*",
                                "/adminAnnList", "/addAnnouncement",
                                "/delAnnouncement/*", "/updateAnnouncement",
                                "/commentList",
                                "/orderAllList", "/orderAllList",
                                "/changeStatus", "/delOrder/*");
            }
        };
    }
}
